package com.luomo.wenyuan.modules.wenyuan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luomo.wenyuan.common.utils.PageUtils;
import com.luomo.wenyuan.common.utils.Query;
import com.luomo.wenyuan.modules.wenyuan.dao.TOrderBookDao;
import com.luomo.wenyuan.modules.wenyuan.entity.TOrderBookEntity;
import com.luomo.wenyuan.modules.wenyuan.service.TOrderBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("tOrderBookService")
public class TOrderBookServiceImpl extends ServiceImpl<TOrderBookDao, TOrderBookEntity> implements TOrderBookService {

    @Autowired
    private TOrderBookDao tOrderBookDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TOrderBookEntity> page = this.page(
                new Query<TOrderBookEntity>().getPage(params),
                new QueryWrapper<TOrderBookEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public Integer getBookNumByPurchaseIdAndBookId(int purchaseId,int bookId) {
        return tOrderBookDao.getBookNumByPurchaseIdAndBookId(purchaseId,bookId);
    }

}